<!doctype html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  <link rel="icon" href="../dist/img/favicon-32x32.png" sizes="32x32" type="image/png">
  <link rel="icon" href="../dist/img/favicon-16x16.png" sizes="16x16" type="image/png">
  <meta name="keywords" content="响应式后台模板,开源免费后台模板,Bootstrap5后台管理系统模板">
  <meta name="description" content="bootstrap-admin基于bootstrap5的免费开源的响应式后台管理模板">
  <meta name="author" content="ajiho">
  <link rel="stylesheet" href="../lib/bootstrap-icons/font/bootstrap-icons.min.css">
  <link rel="stylesheet" href="../lib/bootstrap/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="../dist/css/bootstrap-admin.min.css">
  <title>bootstrap-admin开源免费响应式后台管理系统模板</title>
</head>
<body class="bg-body-tertiary py-3">
<div class="container-fluid">
  <div class="card border-0 shadow-sm">
    <div class="card-body">
      <form id="form">
        <div class="mb-3">
          <label for="name" class="form-label">姓名</label>
          <input type="text" class="form-control" id="name" name="name">
        </div>
        <div class="mb-3">
          <label for="username" class="form-label">用户名</label>
          <input type="text" class="form-control" id="username" name="username">
        </div>
        <div class="mb-3">
          <label for="password" class="form-label">密码</label>
          <input type="text" class="form-control" id="password" name="password">
        </div>
        <div class="mb-3">
          <label for="rePassword" class="form-label">确认密码</label>
          <input type="text" class="form-control" id="rePassword" name="rePassword">
        </div>
        <div class="mb-3">
          <label for="gender-1" class="form-label">性别</label>
          <div>
            <div class="form-check form-check-inline">
              <input class="form-check-input" type="radio" name="gender" checked
                     id="gender-1" value="1">
              <label class="form-check-label" for="gender-1">男</label>
            </div>
            <div class="form-check form-check-inline">
              <input class="form-check-input" type="radio" name="gender"
                     id="gender-2" value="0">
              <label class="form-check-label" for="gender-2">女</label>
            </div>
          </div>
        </div>
        <div class="mb-3">
          <label for="phone" class="form-label">手机</label>
          <input type="text" class="form-control" id="phone" name="phone">
        </div>
        <div class="mb-3">
          <label for="email" class="form-label">邮箱</label>
          <input type="text" class="form-control" id="email" name="email">
        </div>
        <button type="submit" class="btn btn-primary">添加</button>
      </form>
    </div>
  </div>


</div>
<!--回到顶部开始-->
<a href="javaScript:" class="bsa-back-to-top"><i class='bi bi-arrow-up-short'></i></a>
<!--回到顶部结束-->


<script src="../lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="../lib/jquery/dist/jquery.min.js"></script>
<script src="../lib/formvalidation/js/formValidation.js"></script>
<script src="../lib/formvalidation/js/framework/bootstrap.js"></script>
<script src="../lib/formvalidation/js/language/zh_CN.js"></script>
<script src="../dist/js/bootstrap-admin.min.js"></script>
<script src="../dist/js/app.js"></script>
<!--假数据模拟,生产环境中请直接删除该js-->
<script src="../dist/js/bootstrap-admin.mock.js"></script>
<script>


  $("#form").formValidation({
    //验证字段
    fields: {
      name: {
        validators: {
          notEmpty: true
        }
      },
      username: {
        validators: {
          notEmpty: true
        }
      },
      //...
    }
  }).on('success.form.fv', function (e) {
    //阻止表单提交
    e.preventDefault();
    //得到表单对象
    let $form = $(e.target);
    let data = $form.serialize();


    //得到序列化数据
    $.ajax({
      url: "/useradd",
      method: 'post',
      data: data,
      success: function (res) {
        //添加成功
        $.toasts({
          type: 'success',
          content: '添加成功',
          delay:1000,
          autohide: true,
          onHidden:function (){
            parent.modalInstance.setData(true);
            parent.modalInstance.close();
          }
        })

      }
    })

  });


</script>

</body>
</html>
